package com.ttg.common.utils;

import com.ttg.common.exception.BaseException;

import java.util.Objects;

/**
 * Description： Long包装类比较工具
 * Author: chenyou
 * Date: 2025/8/26 9:43
 * Company: ttg
 * Copyright: Copyright (c) 2025
 */
public class LongUtil {

    public static boolean equals(Long a,Long b){
        return Objects.equals(a, b);
    }

    /**
     * 值a < 值b = true
     */
    public static boolean lt(Long a,Long b){
        if(a==null || b==null){
            throw new BaseException("比较值不能为空");
        }
        return a.compareTo(b)<0;
    }

    /**
     * 值a > 值b = true
     */
    public static boolean gt(Long a,Long b){
        if(a==null || b==null){
            throw new BaseException("比较值不能为空");
        }
        return a.compareTo(b)>0;
    }

    public static void main(String[] args) {
        System.out.println(equals(null,null));
        System.out.println(equals(null,1L));
        System.out.println(equals(1L,null));
        System.out.println(equals(1L,1L));
        System.out.println(equals(1L,2L));
        System.out.println("======================");

        System.out.println(lt(1L,2L));
        System.out.println(lt(2L,2L));
        System.out.println(lt(2L,1L));
        System.out.println("======================");

        System.out.println(gt(1L,2L));
        System.out.println(gt(2L,2L));
        System.out.println(gt(2L,1L));
    }
}
